package ar.com.age.distribuidora.presentacion.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import ar.com.age.distribuidora.service.AjusteService;
import ar.com.age.distribuidora.service.AuditoriaChequeService;
import ar.com.age.distribuidora.service.ChequeService;
import ar.com.age.distribuidora.service.ClienteService;
import ar.com.age.distribuidora.service.CompraService;
import ar.com.age.distribuidora.service.ConfiguracionService;
import ar.com.age.distribuidora.service.DatosClienteService;
import ar.com.age.distribuidora.service.DatosProductoService;
import ar.com.age.distribuidora.service.EntregaService;
import ar.com.age.distribuidora.service.InformesService;
import ar.com.age.distribuidora.service.ListaDePrecioService;
import ar.com.age.distribuidora.service.LocalidadService;
import ar.com.age.distribuidora.service.LoteDeCompraService;
import ar.com.age.distribuidora.service.ProductoService;
import ar.com.age.distribuidora.service.ProveedorService;
import ar.com.age.distribuidora.service.UsuarioService;
import ar.com.age.distribuidora.service.VendedorService;
import ar.com.age.distribuidora.service.VentaService;

public class ServiceLocator {

	private static ApplicationContext context;

	private static ApplicationContext getContext() {
		if (context == null) {
			synchronized (ServiceLocator.class) {
				if (context == null) {
					context = new ClassPathXmlApplicationContext(
							"classpath*:**/application-context-webgui.xml");
				}
			}
		}
		return context;
	}
	
	public static ClienteService getClienteService() {
		return (ClienteService) getContext().getBean("clienteService");
	}
	
	public static ListaDePrecioService getListaDePrecioService() {
		return (ListaDePrecioService) getContext().getBean("listaDePrecioService");
	}
	
	public static LocalidadService getLocalidadService(){
		return (LocalidadService)getContext().getBean("localidadService");
	}
	
	public static DatosProductoService getDatosProductoService() {
		return (DatosProductoService) getContext().getBean("datosProductoService");
	}
	
	public static DatosClienteService getDatosClienteService() {
		return (DatosClienteService) getContext().getBean("datosClienteService");
	}
	
	public static ProductoService getProductoService() {
		return (ProductoService) getContext().getBean("productoService");
	}
	
	public static ProveedorService getProveedorService() {
		return (ProveedorService) getContext().getBean("proveedorService");
	}
	
	public static VendedorService getVendedorService() {
		return (VendedorService) getContext().getBean("vendedorService");
	}
	
	public static AjusteService getAjusteService() {
		return (AjusteService) getContext().getBean("ajusteService");
	}
	
	public static LoteDeCompraService getLoteDeCompraService() {
		return (LoteDeCompraService) getContext().getBean("loteDeCompraService");
	}
	
	public static UsuarioService getUsuarioService() {
		return (UsuarioService) getContext().getBean("usuarioService");
	}
	
	public static ChequeService getChequeService() {
		return (ChequeService) getContext().getBean("chequeService");
	}
	
	public static AuditoriaChequeService getAuditoriaChequeService() {
		return (AuditoriaChequeService) getContext().getBean("auditoriaChequeService");
	}

	public static EntregaService getEntregaService() {
		return (EntregaService) getContext().getBean("entregaService");
	}

	public static CompraService getCompraService() {
		return (CompraService) getContext().getBean("compraService");
	}
	
	public static VentaService getVentaService() {
		return (VentaService) getContext().getBean("ventaService");
	}
	public static ConfiguracionService getConfiguracionService(){
		return (ConfiguracionService) getContext().getBean("configuracionService");
	}
	public static InformesService getInformesService(){
		return (InformesService) getContext().getBean("informesService");
	}
		
}